package com.cosyhut.blocks.jode;

import com.jme.math.Matrix3f;
import com.jme.math.Vector3f;

public class ODEJointPoint extends ODESpatial {

	public ODEJointPoint() {
		super();
        this._geom = jode.dCreateSphere(null, 0.001f);
        jode.dGeomTransformSetGeom(this._transform, this._geom);  
	}

    public void attach(ODEBlock block, Vector3f position, Matrix3f rotation) {
        if (null != this._block) {
            this.detach();
        }
        if (null != block) {
            this._block = block;
            jode.dGeomSetBody(this._transform, block.getBody());

            this.setPosition(position);
            this.setRotation(rotation);
        }
    }

    protected void detach() {
        jode.dGeomSetBody(this._transform, null);
        this._block = null;
    }

}
